import { FaceInfo, FaceLibrary, FacialSet } from "@/type/faceLibrary";
import {
    BaseAuthApi,
    ILazyTableService,
    LazyTableService,
} from "@/hooks/useLazyLable";
import axios, { authGuard, Response } from "./axios";
import factorySingleClass from "./SingleClass";

interface FaceLibraryService extends BaseAuthApi {
    DETAIL: string;
}

class FaceLibraryService extends LazyTableService implements ILazyTableService {
    @authGuard
    getList(obj: any) {
        return axios.post(`/mediaslib-service/facelib/get_list`, obj);
    }
    @authGuard
    add(obj: FaceLibrary) {
        return axios.post<Response<any>>(
            `/mediaslib-service/facelib/group/add`,
            obj,
        );
    }
    @authGuard
    remove(id: string) {
        return axios.delete<any>(
            `/mediaslib-service/facelib/delete/face_lib/${id}`,
        );
    }
    @authGuard
    modify(obj: FaceLibrary) {
        return axios.post(`/mediaslib-service/facelib/update/face_lib`, obj);
    }
    @authGuard
    detail(obj: any) {
        return axios.post(`/mediaslib-service/facelib/get/user_list`, obj);
    }
}

class FacialSetService extends LazyTableService implements ILazyTableService {
    getList(obj: any) {
        return axios.post(`/mediaslib-service/facelib/get/user_list`, obj);
    }
    add(obj: FacialSet) {
        return axios.post<Response<any>>(
            `/mediaslib-service/facelib/user/add`,
            obj,
        );
    }
    remove(userLibId: string) {
        return axios.get<any>(
            `/mediaslib-service/facelib/delete/user_list/${userLibId}`,
        );
    }
    getDetail(user_lib_id: string) {
        return axios.get<Response<FacialSet>>(
            `/mediaslib-service/facelib/get/user/details/${user_lib_id}`,
        );
    }
}
const facialSetService = factorySingleClass(FacialSetService);

class FaceService {
    getList(user_lib_id: string) {
        return axios.get<Response<FaceInfo>>(
            `/mediaslib-service/facelib/get/user/details/${user_lib_id}`,
        );
    }
    remove(obj: {
        face_lib_id: string;
        user_lib_id: string;
        user_image: string;
    }) {
        return axios.delete(`/mediaslib-service/facelib/delete/image`, {
            data: obj,
        });
    }
}
const faceService = factorySingleClass(FaceService);
export { facialSetService, faceService };

export default factorySingleClass(FaceLibraryService);
